<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>校园应用系统</title>
  <link rel="stylesheet" th:href="@{/layui/css/css.css}">
  <style>
    .layui-table-view .layui-form-checkbox[lay-skin=primary] i {
      margin-top:8px;
    }
  </style>
</head>
<body>

<input id="dormitoryId" hidden th:attr="value=${dormitorys.dormitoryId}"/>
<input id="dormitoryName" hidden th:attr="value=${dormitorys.dormitoryName}"/>

<div class="layui-body" style="margin-left: -200px">
  <!-- 内容主体区域 -->
  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>学生信息添加</legend>
  </fieldset>
  <div class="demoTable">
    <div class="layui-form-item">
      <label class="layui-form-label">宿舍区域：</label>
      <div class="layui-input-inline" style="width: 120px">
        <input type="text" name="stuName" id="stuName" lay-verify="required" th:attr="value=${dormitorys.area}" autocomplete="off" class="layui-input">
      </div>
      <label class="layui-form-label">宿舍楼号：</label>
      <div class="layui-input-inline " style="width: 120px">
        <input type="text" id="mobile" name="mobile" lay-verify="required" th:attr="value=${dormitorys.buildingNo}" autocomplete="off" class="layui-input">
      </div>
      <label class="layui-form-label">宿舍楼层：</label>
      <div class="layui-input-inline " style="width: 120px">
        <input type="text" id="buildingFloor" name="buildingFloor" lay-verify="required" th:attr="value=${dormitorys.buildingFloor}" autocomplete="off" class="layui-input">
      </div>
      <label class="layui-form-label" style="margin-left: 40px">宿舍名称：</label>
      <div class="layui-input-inline" style="width: 65px">
        <input type="text" name="age" id="age" lay-verify="required" th:attr="value=${dormitorys.dormitoryName}"  autocomplete="off" class="layui-input" width="50px">
      </div>
      <label class="layui-form-label">床位数量：</label>
      <div class="layui-input-inline" style="width: 160px">
        <input type="text" name="idNum" id="idNum" lay-verify ="required" th:attr="value=${dormitorys.bedNumber}" autocomplete="off" class="layui-input" width="50px">
      </div>
      <label class="layui-form-label">管理员：</label>
      <div class="layui-input-inline" style="width: 160px">
        <input type="text" name="idNum" id="dormSupervisor" lay-verify ="required" th:attr="value=${dormitorys.dormSupervisor}" autocomplete="off" class="layui-input" width="50px">
      </div>
    </div>





    <table class="layui-hide" id="demo1" lay-filter="test"></table>





    <script type="text/html" id="barDemo1">
      <!--            <%&#45;&#45;<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>&#45;&#45;%>-->
      <a class="layui-btn layui-btn-xs" lay-event="more">更多 <i class="layui-icon layui-icon-down"></i></a>
    </script>

  </div>

  <div class="layui-footer">
    <!-- 底部固定区域 -->
    校园应用系统
  </div>
</div>
<!--添加界面-->
<div id="insertPage" style="display: none">
  <div class="layui-form-item">
    <label class="layui-form-label">学号：</label>
    <div class="layui-input-block">
      <input type="text" name="title" id="istStuNum" lay-verify="title" autocomplete="off" value="" class="layui-input" style="margin-top: 15px;width: 200px" >
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">姓名：</label>
    <div class="layui-input-block">
      <input type="text" name="title" id="istStuName" lay-verify="title" autocomplete="off" value="" class="layui-input" style="margin-top: 15px;width: 200px" >
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">手机号：</label>
    <div class="layui-input-block">
      <input type="text" name="title" id="istMobile" lay-verify="title" autocomplete="off" value="" class="layui-input" style="margin-top: 15px;width: 200px" >
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">性别：</label>
    <select name="sex" id="istSex" lay-verify="required" lay-search="" class="layui-select" >
      <option value=''>请选择</option>
      <option value='M'>男</option>
      <option value='F'>女</option>
    </select>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">年龄：</label>
    <div class="layui-input-block">
      <input type="text" name="title" id="istAge" lay-verify="title" autocomplete="off" value="" class="layui-input" style="margin-top: 15px;width: 200px" >
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">证件类型：</label>
    <select name="idType" id="istIdType" lay-verify="required" lay-search="" class="layui-select">
      <option value=''>请选择</option>
      <option value='1'>身份证</option>
      <option value='2'>军人证</option>
      <option value='3'>护照</option>
      <option value='4'>户口本</option>
      <option value='5'>外国人永久居留证</option>
      <option value='6'>武警证</option>
      <option value='7'>公章</option>
      <option value='8'>工商营业执照</option>
      <option value='9'>学生证</option>
      <option value='10'>法人代码证</option>
      <option value='11'>士兵证</option>
      <option value='16'>港澳居民来往内地通行证</option>
      <option value='17'>台湾居民来往大陆通行证</option>
      <option value='18'>其他证件类型</option>
    </select>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">证件号码：</label>
    <div class="layui-input-block">
      <input type="text" name="title" id="istIdNum" lay-verify="title" autocomplete="off" value="" class="layui-input" style="margin-top: 15px;width: 300px" >
    </div>
  </div>

  <div class="layui-inline">
    <label class="layui-form-label">出生日期：</label>
    <div class="layui-input-inline">
      <input type="text" name="date" id="istBirthday" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" style="margin-bottom: 15px;width: 300px" >
    </div>
  </div>

  <div>
    <label class="layui-form-label">籍贯：</label>
    <div style="display: inline">
      <select name="istProvince" class="layui-select">
        <option value="">请选择省</option>
      </select>
    </div>
    <span>——</span>
    <div style="display: inline">
      <select name="istCity" class="layui-select" >
        <option value="">请选择市</option>
      </select>
    </div>
    <span>——</span>
    <div style="display: inline">
      <select name="istArea" class="layui-select">
        <option value="">请选择县/区/市</option>
      </select>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">详细信息：</label>
    <div class="layui-input-block">
      <input type="text" name="title" id="istDetailAddr" lay-verify="title" autocomplete="off" value="" class="layui-input" style="margin-top: 15px;width: 300px" >
    </div>
  </div>

  <button class="layui-btn" id="insertStu" style="margin-left: 110px;">确认添加</button>
</div>

<!--   修改界面-->
<div id="updatePage" style="display: none">
  <div class="layui-form-item">
    <label class="layui-form-label">姓名：</label>
    <div class="layui-input-block">
      <input type="text" name="title" id="updStuName" lay-verify="title" autocomplete="off" value="" class="layui-input" style="margin-top: 15px;width: 200px" >
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">手机号：</label>
    <div class="layui-input-block">
      <input type="text" name="title" id="updMobile" lay-verify="title" autocomplete="off" value="" class="layui-input" style="margin-top: 15px;width: 200px" >
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">性别：</label>
    <select name="sex" id="updSex" lay-verify="required" lay-search="" class="layui-select" >
      <option value=''>请选择</option>
      <option value='M'>男</option>
      <option value='F'>女</option>
    </select>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">证件类型：</label>
    <select name="idType" id="updIdType" lay-verify="required" lay-search="" class="layui-select">
      <option value=''>请选择</option>
      <option value='1'>身份证</option>
      <option value='2'>军人证</option>
      <option value='3'>护照</option>
      <option value='4'>户口本</option>
      <option value='5'>外国人永久居留证</option>
      <option value='6'>武警证</option>
      <option value='7'>公章</option>
      <option value='8'>工商营业执照</option>
      <option value='9'>学生证</option>
      <option value='10'>法人代码证</option>
      <option value='11'>士兵证</option>
      <option value='16'>港澳居民来往内地通行证</option>
      <option value='17'>台湾居民来往大陆通行证</option>
      <option value='18'>其他证件类型</option>
    </select>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">证件号码：</label>
    <div class="layui-input-block">
      <input type="text" name="title" id="updIdNum" lay-verify="title" autocomplete="off" value="" class="layui-input" style="margin-top: 15px;width: 300px" >
    </div>
  </div>


  <div>
    <label class="layui-form-label">籍贯：</label>
    <div style="display: inline">
      <select name="province" class="layui-select">
        <option value="">请选择省</option>
      </select>
    </div>
    <span>——</span>
    <div style="display: inline">
      <select name="city" class="layui-select" >
        <option value="">请选择市</option>
      </select>
    </div>
    <span>——</span>
    <div style="display: inline">
      <select name="area" class="layui-select">
        <option value="">请选择县/区/市</option>
      </select>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">详细信息：</label>
    <div class="layui-input-block">
      <input type="text" name="title" id="updDetailAddr" lay-verify="title" autocomplete="off" value="" class="layui-input" style="margin-top: 15px;width: 300px" >
    </div>
  </div>

  <button class="layui-btn" id="updateStu" style="margin-left: 110px;">确认修改</button>
</div>
</div>
<script th:src="@{/layui/layui.js}"></script>
<script th:src="@{/js/jquery-1.8.3.js}"></script>
<script th:src="@{/thymeleaf/dormitoryStu.js}"></script>
<script>

  // 使用es6的padStart()方法来补0
  function getYMDHMS (timestamp) {
    let time = new Date(timestamp)
    let year = time.getFullYear()
    const month = (time.getMonth() + 1).toString().padStart(2, '0')
    const date = (time.getDate()).toString().padStart(2, '0')
    const hours = (time.getHours()).toString().padStart(2, '0')
    const minute = (time.getMinutes()).toString().padStart(2, '0')
    const second = (time.getSeconds()).toString().padStart(2, '0')

    return year + '-' + month + '-' + date + ' ' + hours + ':' + minute + ':' + second;
  }




  //JS
  layui.use(['element', 'layer', 'util'], function(){
    var element = layui.element
            ,layer = layui.layer
            ,util = layui.util
            ,$ = layui.$;

    //头部事件
    util.event('lay-header-event', {
      //左侧菜单事件
      menuLeft: function(othis){
        layer.msg('展开左侧菜单的操作', {icon: 0});
      }
      ,menuRight: function(){
        layer.open({
          type: 1
          ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
          ,area: ['260px', '100%']
          ,offset: 'rt' //右上角
          ,anim: 5
          ,shadeClose: true
        });
      }
    });

  });

  layui.config({
    version: '1623988781494' //为了更新 js 缓存，可忽略
  });
  layui.use('form', function(){
    var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功

    //……

    //如果你的 HTML 是动态生成的，自动渲染就会失效
    //因此你需要在相应的地方，执行下述方法来进行渲染

    form.render('select');
  });
  layui.use('laydate', function(){
    var laydate = layui.laydate;

    //执行一个laydate实例
    laydate.render({
      elem: '#istBirthday' //指定元素
    });
  });

</script>
</body>
</html>
